﻿using System;
using System.Windows.Forms;
using WF = System.Windows.Forms;

namespace UpwardsTimeClock.Prototype
{
    public class ClockControl : VisualControlBase<Clock>
    {
        private WF.Label _label;

        public ClockControl(Clock config)
            : base(config)
        {
            _label = LabelControl.CreateLabel(config);
        }

        protected override Control CreateVisualControl()
        {
            return _label;
        }

        public override void Start()
        {
            base.Start();

            UpdateTimer();
        }

        private void UpdateTimer()
        {
            string formattedTimer = DateTime.Now.ToString(Config.Text);
            _label.Text = formattedTimer;
            _label.Refresh();
        }

        public override void Timer()
        {
            base.Timer();
            UpdateTimer();
        }
    }
}
